<admintpl file="header" />
</head>
<body>
<div class="wrap js-check-wrap">
	<ul class="nav nav-tabs">
		<li><a href="{:U('Store/index')}">店铺列表</a></li>
		<li class="active"><a href="{:U('Store/insert')}" target="_self">添加店铺</a></li>
	</ul>
	<form action="{:U('Store/insert')}" method="post" class="form-horizontal js-ajax-forms" enctype="multipart/form-data">
		<div class="row-fluid">
			<div class="span9">
				<table class="table table-bordered">
					<tr>
						<th>用户名</th>
						<td>
							<input type="text" style="width:400px;" name="login_name" id="login_name" required value="" placeholder="请输入用户名"/>
							<span class="form-required">*商家登陆账号</span>
						</td>
					</tr>
					<tr>
						<th>密码</th>
						<td>
							<input type="password" style="width:400px;" name="password" id="password" required value="" placeholder="请输入密码"/>
							<span class="form-required">*商家登陆密码</span>
						</td>
					</tr>
					<tr>
						<th>确认密码</th>
						<td>
							<input type="password" style="width:400px;" name="confirm_password" id="confirm_password" required value="" placeholder="请输入密码"/>
							<span class="form-required">*商家登陆密码</span>
						</td>
					</tr>
					<tr>
						<th>手机号</th>
						<td>
							<input type="text" name="phone_mob" id="phone_mob" required style="width: 400px" placeholder="请输入手机号">
							<span class="form-required">*商家手机号</span>
						</td>
					</tr>
					<tr>
						<th>邮箱</th>
						<td>
							<input type="text" name="email" id="email"  style="width: 400px" placeholder="请输入邮箱">
							<span class="form-required">商家邮箱号</span>
						</td>
					</tr>
					<tr>
						<th>店铺名称</th>
						<td>
							<input type="text" name="store_name" required id="store_name"  style="width: 400px" placeholder="请输入店铺名称">
							<span class="form-required">*店铺名称</span>
						</td>
					</tr>
					<tr>
						<th>最低分佣比例</th>
						<td>
							<input type="text" name="min_sub" required id="min_sub"  style="width: 400px" placeholder="请输入最低分佣比例">
							<span class="form-required">*最低分佣比例  请输入小数！</span>
						</td>
					</tr>
					<tr>
						<th>销售总金额比较值</th>
						<td>
							<input type="text" name="sub_money"  id="sub_money"  style="width: 400px" placeholder="销售总金额比较值">
							<span class="form-required">单位：元 注：超过比较值金额 系统自动匹配最高分佣比例！</span>
						</td>
					</tr>
					<tr>
						<th>最高分佣比例</th>
						<td>
							<input type="text" name="max_sub"  id="max_sub"  style="width: 400px" placeholder="最高分佣比例">
							<span class="form-required">最高分佣比例  请输入小数！</span>
						</td>
					</tr>
					<tr>
						<th>选择结算方式</th>
						<td>
							<label class="radio"><input type="radio" name="settlement_method" value="clique">集团结算</label>
							<label class="radio"><input type="radio" name="settlement_method" value="shop">店铺结算</label>
						</td>
					</tr>
					<tr>
						<th>是否按照地区选择用户</th>
						<td>
							<label class="radio"><input type="radio" name="is_region_choice" value="1">是</label>
							<label class="radio"><input type="radio" name="is_region_choice" value="0" checked>否</label>
						</td>
					</tr>
					<tr>
						<th>是否为总店铺</th>
						<td>
							<label class="radio"><input type="radio" name="is_main" value="1" checked>是</label>
							<label class="radio"><input type="radio" name="is_main" value="0">否</label>
						</td>
					</tr>
					<tr>
						<th>是否开启店铺归属码</th>
						<td>
							<label class="radio"><input type="radio" name="attribution_switch" value="1" checked>是</label>
							<label class="radio"><input type="radio" name="attribution_switch" value="0">否</label>
						</td>
					</tr>
					<tr>
						<th>店铺归属码</th>
						<td>
							<input type="text" name="attribution_code"  id="attribution_code"  style="width: 400px" placeholder="请填写店铺归属码">
							<span class="form-required">请确认上方按钮是否开启，不开启填写无效！</span>
						</td>
					</tr>
					<tr style="display: none" id="parent">
						<th>选择总店铺</th>
						<td>
							<select style="min-width: 190px;" name="parent_id">
								<option value="0">请选择店铺</option>
								<volist name="storeList" id="re">
									<option value="{$re.store_id}">{$re.store_name}</option>
								</volist>
							</select>
						</td>
					</tr>
					<tr>
						<th>地区</th>
						<td>
							<select style="min-width: 190px;" name="region1" id="lc-select1-region">
								<option value="0">请选择</option>
								<volist name="region1" id="re">
									<option value="{$re.region_id}">{$re.region_name}</option>
								</volist>
							</select>
							<select class="p-no-margin form-control" name="region2" value="0" id="lc-select2-region" style="display: none; width: auto;">
								<option value="0">请选择</option>
							</select>
							<input style="display: none;" id="lc-input-region_name" name="region_name">
						</td>
					</tr>
					<tr>
						<th>地址</th>
						<td>
							<input type="text" name="address"  id="address"  style="width: 400px" placeholder="请输入地址信息">
							<span class="form-required">*详细地址</span>
						</td>
					</tr>
					<tr>
						<th>小程序抬头名称</th>
						<td>
							<input type="text" name="logo_name"  id="logo_name"  style="width: 400px" placeholder="请输入小程序抬头名称">
							<span class="form-required">*小程序抬头名称</span>
						</td>
					</tr>

				</table>
			</div>
			<div class="span3">
				<table class="table table-bordered">
					<tr>
						<th><b>logo</b></th>
					</tr>
					<tr>
						<td>
							<div style="text-align: center;">
								<input type="hidden" name="store_logo" id="thumb" value="">
								<a href="javascript:upload_one_image('图片上传','#thumb');">
									<img src="__TMPL__Public/assets/images/default-thumbnail.png" id="thumb-preview" width="135" style="cursor: hand" />
								</a>
								<input type="button" class="btn btn-small" onclick="$('#thumb-preview').attr('src','__TMPL__Public/assets/images/default-thumbnail.png');$('#thumb').val('');return false;" value="取消图片">
							</div>
						</td>
					</tr>
				</table>
			</div>
		</div>
		<div class="form-actions">
			<button class="btn btn-primary js-ajax-submit" type="submit">提交</button>
			<a class="btn" href="{:U('Store/index')}">返回</a>
		</div>
	</form>
</div>
<script type="text/javascript" src="__PUBLIC__/js/common.js"></script>

	<script>

        $("input[name=is_main]").change(function(){
            var is_show_gift = $('input[name=is_main]:checked').val();
            if(is_show_gift == 0){
                $("#parent").show();
            }else{
                $("#parent").hide();
            }
        })


		var region = '';
		$("#lc-select1-region").on('change',function () {
			if($(this).val()){
                $.ajax({
                    type:"post",
                    url:"{:U('Store/getRegion')}",
                    async:true,
                    data:{'parent_id':$(this).val()},
                    dataType:"json",
                    success:function(result) {
                        if (result.code == 10000) {
                            var shtml = '';
                            for(var i in result.data){
                                shtml += '<option value="'+result.data[i].region_id+'">'+result.data[i].region_name+'</option>'
							}
                            var start = '<option value="0" selected>请选择</option>'
                            $("#lc-select2-region").html(start+shtml)
                            $("#lc-select2-region").css('display','');
                            $("#lc-select3-region").css('display','none');
                            change_region();
                        }
                    }
				});
			}
        })
        // $("#lc-select2-region").on('change',function () {
        //     if($(this).val()){
        //         $.ajax({
        //             type:"post",
        //             url:"{:U('Store/getRegion')}",
        //             async:true,
        //             data:{'parent_id':$(this).val()},
        //             dataType:"json",
        //             success:function(result) {
        //                 if (result.code == 10000) {
        //                     var shtml = '';
        //                     for(var i in result.data){
        //                         shtml += '<option value="'+result.data[i].region_id+'">'+result.data[i].region_name+'</option>'
        //                     }
        //                     var start = '<option value="0" selected>请选择</option>'
        //                     $("#lc-select3-region").html(start+shtml)
        //                     $("#lc-select3-region").css('display','');
        //                     change_region();
        //                 }
        //             }
        //         });
        //     }
        // })
        $("#lc-select3-region").on('change',function () {
            change_region();
        });
		function change_region() {
		    region = ''
            console.log($("#lc-select3-region").val())
            if($("#lc-select1-region").val() != 0){
                region += $("#lc-select1-region option:selected").text() + ' ';
            }
            if($("#lc-select2-region").val() != 0){
                region += $("#lc-select2-region option:selected").text() + ' ';
            }
            if($("#lc-select3-region").val() != 0){
                region += $("#lc-select3-region option:selected").text() + ' ';
            }
            $("#lc-input-region_name").val(region);
            console.log($("#lc-input-region_name").val())
        }
        $("#lc-btn-return").click(function () {
			location.href = "{:U('Store/index')}";
        })
    </script>
	</body>
</html>
